import numpy

class Verlet:
    
    @classmethod
    def Integrate(cls, points, prev_points, dump_factor, force):
        pos_x = numpy.matrix(points[:,:,0], copy=False)
        pos_y = numpy.matrix(points[:,:,1], copy=False)
        pos_z = numpy.matrix(points[:,:,2], copy=False)
        old_pos_x = numpy.matrix(prev_points[:,:,0], copy=False)
        old_pos_y = numpy.matrix(prev_points[:,:,1], copy=False)
        old_pos_z = numpy.matrix(prev_points[:,:,2], copy=False)
        a_x = force[0]
        a_y = force[1]
        a_z = force[2]
        pos_x = (2 - dump_factor) * pos_x - (1 - dump_factor) * old_pos_x + a_x
        pos_y = (2 - dump_factor) * pos_y - (1 - dump_factor) * old_pos_y + a_y
        pos_z = (2 - dump_factor) * pos_z - (1 - dump_factor) * old_pos_z + a_z
        tmp = prev_points
        prev_points = points
        tmp[:,:,0] = pos_x
        tmp[:,:,1] = pos_y
        tmp[:,:,2] = pos_z
        points = tmp
        return points, prev_points